$(document).ready(function () {
   $("#createBtn").on('click',function (e) {
       //获取选中的值
       var obj = $("input[name='string']");
       var strObj = [];
       for (var i=0;i<obj.length;i++){
           if(obj[i].checked){
               strObj.push(obj[i].value);
           }
       }
       //获取生成密码的长度
       var passwordLength = parseInt($('#passwordLength').val());
       var password= "";
       for (var j=1;j<=passwordLength;j++){
           //必须带
           do{
               var strIndex = parseInt(Math.floor(Math.random()*strObj.length));
               var index = parseInt(Math.floor(Math.random()*(strObj[strIndex].length)))+1;
               var passwordstr =strObj[strIndex].substr((index-1),1).toString();
           }
           while(password.indexOf(passwordstr) > 0);
           password += passwordstr;
       }
       $("#createPassword").attr('value',password.toString());
   })
});